<template>
    <!-- 汇总评价列表 -->
    <div class="e-table">
        <div class="top">
            <div class="left" style="margin-left: 10px">
                <div>
                    <el-button
                        size="mini"
                        @click="buttonAdd1()"
                        style="background: #7aa818; color: #fff"
                        >分子公司新增汇总评价</el-button
                    >
                    <el-button
                        size="mini"
                        @click="buttonAdd2()"
                        style="background: #7aa818; color: #fff"
                        >集团新增汇总评价</el-button
                    >
                </div>
            </div>
            <div class="right">
                <div>
                    <el-input
                        placeholder=""
                        v-model="advancedQuery.keyword"
                        @keyup.enter.native="getData"
                    >
                        <i
                            slot="suffix"
                            style="cursor: pointer"
                            @click="getData"
                            class="el-icon-search"
                        ></i>
                    </el-input>
                </div>
                <div>
                    <el-button
                        size="small"
                        style="
                            background: #2e61d7;
                            color: #fff;
                            margin-left: 5px;
                        "
                        >高级搜索</el-button
                    >
                </div>
            </div>
        </div>

        <el-table
            border
            ref="table"
            :data="tableData"
            tooltip-effect="dark"
            class="table"
            style="width: 100%"
            @selection-change="handleSelectionChange"
            @cell-mouse-enter="cellMouseEnter"
            @cell-mouse-leave="cellMouseLeave"
            v-sortTable="{ tableData: tableData, _this: this, ref: 'table' }"
        >
            <el-table-column type="selection" width="50" v-if="isBatch">
            </el-table-column>
            <el-table-column show-overflow-tooltip label="操作" width="100px">
                <template slot-scope="scope">
                    <div>
                        <i
                            class="el-icon-edit"
                            style="cursor: pointer; font-size: 20px"
                            :class="{
                                'icon-edit-active-color':
                                    MouseEnterId == scope.row.id
                            }"
                            @click="tableDbEdit(scope.row.id)"
                        ></i>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="机构名称" min-width="600">
                <template slot-scope="scope">
                    <span
                        @click="articulars(scope.row.id, scope.row.isGroup)"
                        style="color: blue; cursor: pointer"
                    >
                        {{ scope.row.orgName }}
                    </span>
                </template>
            </el-table-column>
            <el-table-column
                prop="evaluateDate"
                label="评价日期"
                width="250"
                show-overflow-tooltip
            >
            </el-table-column>

            <el-table-column
                prop="summartDate"
                label="汇总时间区间"
                width="250"
                show-overflow-tooltip
            >
            </el-table-column>
            <el-table-column
                prop="state"
                label="状态"
                width="220"
                show-overflow-tooltip
            >
                <template slot-scope="scope">
                    <span>
                        {{
                            ['草稿', '审核中', '已审核'][scope.row.state]
                        }}</span
                    >
                </template>
            </el-table-column>
            <el-table-column
                prop="releasestate"
                label="发布状态"
                width="210"
                show-overflow-tooltip
            >
                <template slot-scope="scope">
                    <span>
                        {{ ['未发布', '发布'][scope.row.releasestate] }}</span
                    >
                </template>
            </el-table-column>
        </el-table>

        <ComPagination />
    </div>
</template>
<script>
import ComPagination from '@/components/pagination/pagination.vue'
import { advanceSearch } from '@/utils/common.js'
export default {
    components: {
        ComPagination
    },
    data () {
        return {
            isBatch: false, //是否进入批量操作
            batch: '进入批量管理',
            tableData: [
                {
                    orgName: '', //工程分包商名称
                    evaluateDate: '', //评价日期
                    summartDate: '', //汇总时间区间
                    state: '', //状态
                    releasestate: '' //发布状态
                }
            ],
            advancedQuery: {
                creditGrade: [], //信用等级
                grade: [], //资质等级
                isAbroadUnit: null, //境外单位
                keyword: '', //	模糊查询关键字
                limit: 20, //每页显示条数
                main: [], //主营范围
                manageOrg: [], //管理单位
                orgId: '', //单据机构
                outerType: [], //外包方类型
                page: 1, //当前页数
                startCapital: null, //开始注册资本
                endCapital: null, //结束注册资本
                states: [], //单据状态
                creditCode: '', //信用代码
                subcontractorName: '' //分包商名称
            },
            MouseEnterId: 0
        }
    },
    created () {
        this.getData()
    },
    mounted () {},
    methods: {
        //批量管理
        batchOperation () {
            this.isBatch = !this.isBatch
            if (this.isBatch) {
                this.batch = '退出批量管理'
                this.$refs.table.clearSelection()
            } else {
                this.batch = '进入批量管理'
            }
        },
        cellMouseEnter (row) {
            this.MouseEnterId = row.id
        },
        cellMouseLeave () {
            this.MouseEnterId = 0
        },
        //查询分包商列表数据
        getData () {
            this.$Ajax
                .httpPost({
                    url: '/outer/summary/listByEntity',
                    params: {
                        keyword: '',
                        limit: 10,
                        page: 1
                    }
                })
                .then(res => {
                    this.tableData = res.list
                })
        },
        //新增按钮
        buttonAdd1 () {
            this.$router.push('/filialeCollectAdd')
        },
        buttonAdd2 () {
            this.$router.push('/groupCollectAdd')
        },
        //详情
        articulars (id, isGroup) {
            console.log(id, isGroup)
            if (isGroup == 0) {
                this.$router.push({
                    path: '/filialeCollectExamine',
                    query: { id }
                })
            } else {
                this.$router.push({
                    path: '/groupCollectExamine',
                    query: { id }
                })
            }
        },
        //编辑
        tableDbEdit (id, isGroup) {
            console.log(id, isGroup)
            if (isGroup == 0) {
                this.$router.push({
                    path: '/filialeCollectEdit',
                    query: { id }
                })
            } else {
                this.$router.push({
                    path: '/groupCollectEdit',
                    query: { id }
                })
            }
        },
        handleSelectionChange (val) {
            this.multipleSelection = val
        },
        //高级查询
        onAdvanceSearch () {
            advanceSearch('/collectEvaluateSearch?type=1').then(res => {
                this.advancedQuery.outerType = res.subcontractorTypeValue //外包方类型
                this.advancedQuery.isAbroadUnit = res.isAbroadUnit //境外单位
                this.advancedQuery.creditGrade = res.creditLevelTypeValue //信用等级
                this.advancedQuery.states = res.stateTypeValue //状态
                this.advancedQuery.startCapital = res.startCapital //开始资本
                this.advancedQuery.endCapital = res.endCapital //结束资本
                this.advancedQuery.grade = res.grade //资质等级
                this.advancedQuery.main = res.main //主营范围
                this.advancedQuery.manageOrg = res.manageOrg //管理单位
                this.advancedQuery.subcontractorName = res.subcontractorName //分包商名称
                this.advancedQuery.creditCode = res.creditCode //信用代码
                this.getData()
            })
        }
    }
}
</script>
<style lang="scss" scoped>
.like {
    color: rgb(46, 97, 215);
    font-size: 17px;
    line-height: 30px;
    cursor: pointer;
}
::v-deep.el-table .cell {
    text-align: center;
}
::v-deep .el-table__body-wrapper::-webkit-scrollbar {
    width: 6px; // 横向滚动条
    height: 10px; // 纵向滚动条
}
// 滚动条的滑块
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 5px;
}
</style>
